/**   
 * Copyright © 2019 eSunny Info. Tech Ltd. All rights reserved.
 * 
 * @Description:TODO(功能)
 * @className outLoginServlet.java
 * @Package: com.bus.servlet 
 * @author: yj   
 * @date: 2019年1月26日 下午4:56:06 
 */
package com.erp.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @className outLoginServlet.java
 * @author yj
 * @Description:TODO(功能)
 * @Date 2019年1月26日
 */
@WebServlet("/outLogin")
public class outLoginServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		// 解决中文乱码
		/*request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");*/
		
		PrintWriter out = response.getWriter();
		
		HttpSession session = request.getSession(false);
		if (session != null) {
			session.removeAttribute("loginName");
			//response.sendRedirect("index.jsp");
			out.write("<script>parent.location.href='index.jsp'</script>");  // 全局跳出
			
		} else {
			out.write("<script>alert('退出失败!');</script>");
		}
		
		
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) 
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}

}
